import java.util.Random;
import java.util.Scanner;

public class GuessNumberGame {
    private static final Random random = new Random();
    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int numberToGuess = random.nextInt(100) + 1; // 生成一个1到100之间的随机数
        int maxTries = 10; // 玩家最多可以猜10次
        System.out.println("猜数字游戏开始！我已经想好了一个1到100之间的数字。你有" + maxTries + "次机会猜中它。");

        for (int tries = 1; tries <= maxTries; tries++) {
            System.out.print("请输入你猜的数字：");
            int guess = scanner.nextInt();

            if (guess == numberToGuess) {
                System.out.println("恭喜你！你猜对了数字是：" + numberToGuess);
                break;
            } else if (guess < numberToGuess) {
                System.out.println("太小了，请再试一次。");
            } else if (guess > numberToGuess) {
                System.out.println("太大了，请再试一次。");
            }

            if (tries == maxTries) {
                System.out.println("很遗憾，你的机会用完了。我想的数字是：" + numberToGuess);
            }
        }

        System.out.println("游戏结束，感谢你的参与！");
        scanner.close();
    }
}